<?php
class memberinfomod extends MY_Model{
	
	function memberinfomod(){
		parent::__construct(
			"member_info",
			array(
				"id_member", //---> load from id_member & set as primary key
				"first_name",
				"last_name",
				"born_place",
				"birthday",
				"about"
			),
			array("id_member")
		);
	}
		
	function add($newData){
		$this->db->insert($this->table_name, $newData);
	}
	
	function update($id,$newData){
		$this->db->where($this->table_fields[0], $id);
		return $this->db->update($this->table_name, $newData);
	}
	
	function delete($ids){
		if (!is_array($ids)) $ids = array($ids);
    	foreach($ids as $pk) {
    		$this->db->or_where($this->table_fields[0], $pk);	
    	}
    	return $this->db->delete($this->table_name, $pk);
	}
	
	function remove($ids){
    	return $this->db->delete($this->table_name, array($this->table_fields[0]=>$ids));
    }
	
 	function get($id){
		return $this->db->get_where($this->table_name, array($this->table_fields[0]=>$id));
    }
    
	function get_record($limit=0,$offset=20){
		$this->db->limit($offset,$limit);
		return $this->db->get($this->table_name);
    }

	function get_where($where,$limit=0,$offset=20){
//    	return $this->db->get_where($this->table_name, $where, $limit, $offset);
		$this->db->like('first_name',$where,'both');
		$this->db->or_like('last_name',$where,'both');
		$this->db->or_like('born_place',$where,'both');
		$this->db->or_like('birthday',$where,'both');
		$this->db->or_like('about',$where,'both');
		$this->db->limit($offset,$limit);
    	return $this->db->get($this->table_name);
    } 
    
}